package com.zjsru.plan2023.oneday;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: CookLee
 * @Date: 2023/5/28
 * 老人的数目
 * 输入：details = ["7868190130M7522","5303914400F9211","9273338290F4010"]
 * 输出：2
 * 解释：下标为 0 ，1 和 2 的乘客年龄分别为 75 ，92 和 40 。所以有 2 人年龄大于 60 岁。
 *
 * 输入：details = ["1313579440F2036","2921522980M5644"]
 * 输出：0
 * 解释：没有乘客的年龄大于 60 岁。
 */
public class CountSeniors {
    
    public int countSeniors(String[] details) {
        List<Integer> ages = new ArrayList<>();
        for (String s:details) {
            ages.add(Integer.parseInt(s.substring(11,13)));
        }
        return (int) ages.stream().filter(v -> v > 60).count();
    }
    
    public static void main(String[] args) {
        CountSeniors countSeniors = new CountSeniors();
        String[] details = new String[]{"7868190130M7522","5303914400F9211","9273338290F4010"};
        System.out.println(countSeniors.countSeniors(details));
    }
}
